home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / ccmd / cmfnc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-03  |  13.0 KB  |  524 lines

  1. /*
  2.  Author: Andrew Lowry
  3.  
  4.  Columbia University Center for Computing Activities, July 1986.
  5.  Copyright (C) 1986, 1987, Trustees of Columbia University in the City
  6.  of New York.  Permission is granted to any individual or institution
  7.  to use, copy, or redistribute this software so long as it is not sold
  8.  for profit, provided this copyright notice is retained.
  9. */
  10. /* cmfnc.h
  11. **
  12. ** This file contains function-specific symbols and declarations needed
  13. ** by application programs that wish to make use of the ccmd package.
  14. ** It is generated by m4 by means of the cmfnc.h4 file in conjunction with
  15. ** individual configuration files (as in cm???.cnf).  The initial portion
  16. ** of the file, including this comment, is copied verbatim from the file
  17. ** cmfnc.top.
  18. **
  19. ** Function codes are given names like _CMTTT, where TTT is the three-
  20. ** letter abbreviation for the type, and are assigned small positive
  21. ** integer values.
  22. **
  23. ** Function-specific error codes are given names of the form TTTxEEE,
  24. ** where TTT is the three-letter abbreviation for the parse type, and
  25. ** EEE is an abbreviation for the error.  The values assigned to these
  26. ** symbols are in two parts.  The left half contains the function code
  27. ** for the parse function, and the right half contains an integer
  28. ** in the range 0 to n-1, where there are n errors defined for the parse
  29. ** type.  Generic error codes for the ccmd package as a whole are given
  30. ** names like CMxEEE, and have zeros in the left half.
  31. **
  32. ** Flag values are generally given names like TTT_FFF, where FFF is a
  33. ** mnemonic for the flag.  Other constants are given names like _TTTCCC,
  34. ** where CCC is a mnemonic for the constant.
  35. **/
  36.  
  37. /* Macro to build error code values from the function code and error
  38. ** sub-code values.
  39. **/
  40.  
  41. #define CMERR(fcode,ecode)    ((fcode << 8) | ecode)
  42.  
  43.  
  44.  
  45. /* Generic ccmd package error codes, all with zero in left half */
  46.  
  47. #define CMxOK    CMERR(0,0)
  48. #define CMxRPT    CMERR(0,1)
  49. #define CMxNOP    CMERR(0,2)
  50. #define CMxUNKF    CMERR(0,3)
  51. #define CMxBOVF    CMERR(0,4)
  52. #define CMxAOVF    CMERR(0,5)
  53. #define CMxEOF    CMERR(0,6)
  54. #define CMxINC    CMERR(0,7)
  55. #define CMxNFDB    CMERR(0,8)
  56. #define CMxGO    CMERR(0,9)
  57. #define CMxDFR    CMERR(0,10)
  58. #define CMxNOAR    CMERR(0,11)
  59. #define CMxNDEF    CMERR(0,12)
  60. #define CMxIOVF    CMERR(0,13)
  61. #define CMxIO    CMERR(0,14)
  62. #define CMxBUFS    CMERR(0,15)
  63. #define CMxPMT    CMERR(0,16)
  64. #define CMxAGN    CMERR(0,17)
  65. #define CMxNOAE    CMERR(0,18)
  66. #define CMxBEL    CMERR(0,19)
  67. #define CMxBEG    CMERR(0,20)
  68. #define CMxSOF    CMERR(0,21)
  69. #define CMxSUF    CMERR(0,22)
  70.  
  71. /* Configuration information for cmcfm */
  72.  
  73. #define _CMCFM 1
  74.  
  75. /* Macro to prevent loading of cmcfm support */
  76.  
  77. #define CFM_STUB ftspec ft_cfm = { NULL, NULL, NULL, 0, NULL }; \
  78.     fnerr fe_cfm = { 0, NULL };
  79.  
  80.  
  81. /* cfm error codes */
  82.  
  83. #define CFMxNOC    CMERR(1,0)
  84.  
  85. /* Configuration information for cmkey */
  86.  
  87. #define _CMKEY 2
  88.  
  89. /* Macro to prevent loading of cmkey support */
  90.  
  91. #define KEY_STUB ftspec ft_key = { NULL, NULL, NULL, 0, NULL }; \
  92.     fnerr fe_key = { 0, NULL };
  93.  
  94.  
  95. /* keyword parse errors */
  96.  
  97. #define KEYxNM    CMERR(2,0)
  98. #define KEYxAMB    CMERR(2,1)
  99. #define KEYxABR    CMERR(2,2)
  100.  
  101. /*
  102.  * KEYWRD structure specifies one entry in a keyword table.  KEYTAB
  103.  * structure describes a table of keywords.
  104.  */
  105.  
  106. #ifdef notdef
  107. /*
  108.  * we want to return "anything" as the value of a keyword,
  109.  * so we need to know what is the 'largest' type in a machine independent 
  110.  * way.   I can't figure out a way to do this at compile time, so we'll use a 
  111.  * generated  file.
  112.  */
  113.  
  114. #include "cmkeyval.h"        /* this defines the keyval type */
  115. #endif
  116.  
  117. #ifdef KEYVAL_TYPE
  118. typedef KEYVAL_TYPE keyval;
  119. #else
  120. typedef long keyval;
  121. #endif
  122.  
  123.  
  124. typedef struct KEYWRD {
  125.     char *    _kwkwd;    /* keyword string */
  126.     short    _kwflg;    /* flags (see below) */
  127.     keyval    _kwval;    /* arbitrary value, not used internally */
  128.             /*  except for abbreviations... see KEY_ABR */
  129.             /*  flag below */
  130. } keywrd;
  131.  
  132. typedef struct KEYTAB {
  133.     int    _ktcnt;    /* number of keywords in table */
  134.     keywrd * _ktwds;/* array of keyword entries */
  135. } keytab;
  136.  
  137. /* Valid flags in fdb */
  138. #define KEY_EMO 0x0001        /* exact match only */
  139.  
  140. /* flags that can be present in a keyword entry */
  141.  
  142. #define KEY_ABR 0x0002        /* keyword is an abbreviation for the */
  143.             /* keyword indexed by this entry's _kwval value */
  144.  
  145. #define KEY_NOR 0x0004        /* Ignore this keyword (do not recognize */
  146.             /*  any prefix, or even an exact match) */
  147. #define KEY_IGN KEY_NOR
  148. #define KEY_INV 0x0008        /* Invisible keyword (not shown with help) */
  149. #define KEY_MAT 0x0010        /* This keyword matches current input */
  150.             /*  (used internally) */
  151.  
  152.  
  153. /* Configuration information for cmnum */
  154.  
  155. #define _CMNUM 3
  156.  
  157. /* Macro to prevent loading of cmnum support */
  158.  
  159. #define NUM_STUB ftspec ft_num = { NULL, NULL, NULL, 0, NULL }; \
  160.     fnerr fe_num = { 0, NULL };
  161.  
  162.  
  163. /* number parsing errors */
  164.  
  165. #define NUMxRAD    CMERR(3,0)
  166. #define NUMxSGN    CMERR(3,1)
  167. #define NUMxNP    CMERR(3,2)
  168. #define NUMxOV    CMERR(3,3)
  169.  
  170. /* Parse flags for number parse */
  171.  
  172. #define NUM_US 0x0001        /* unsigned integer parse */
  173. #define NUM_BNP 0x0002        /* integer can break on non-punctuation */
  174. #define NUM_PO 0x0004        /* parse-only (no conversion to binary) */
  175.  
  176. /* Configuration information for cmqst */
  177.  
  178. #define _CMQST 4
  179.  
  180. /* Macro to prevent loading of cmqst support */
  181.  
  182. #define QST_STUB ftspec ft_qst = { NULL, NULL, NULL, 0, NULL }; \
  183.     fnerr fe_qst = { 0, NULL };
  184.  
  185.  
  186. /* quoted string error codes */
  187.  
  188. #define QSTxQC    CMERR(4,0)
  189. #define QSTxBC    CMERR(4,1)
  190. #define QSTxNP    CMERR(4,2)
  191.  
  192. /* Configuration information for cmnoi */
  193.  
  194. #define _CMNOI 5
  195.  
  196. /* Macro to prevent loading of cmnoi support */
  197.  
  198. #define NOI_STUB ftspec ft_noi = { NULL, NULL, NULL, 0, NULL }; \
  199.     fnerr fe_noi = { 0, NULL };
  200.  
  201.  
  202. /* noise word parse errors */
  203.  
  204. #define NOIxNP    CMERR(5,0)
  205.  
  206. /* Configuration information for cmtxt */
  207.  
  208. #define _CMTXT 6
  209.  
  210. /* Macro to prevent loading of cmtxt support */
  211.  
  212. #define TXT_STUB ftspec ft_txt = { NULL, NULL, NULL, 0, NULL }; \
  213.     fnerr fe_txt = { 0, NULL };
  214.  
  215. /* text line parse errors */
  216.  
  217. #define TXTxNP    CMERR(6,0)
  218.  
  219. /* Configuration information for cmfld */
  220.  
  221. #define _CMFLD 7
  222.  
  223. /* Macro to prevent loading of cmfld support */
  224.  
  225. #define FLD_STUB ftspec ft_fld = { NULL, NULL, NULL, 0, NULL }; \
  226.     fnerr fe_fld = { 0, NULL };
  227.  
  228.  
  229. /* Field (word) parse errors */
  230.  
  231. #define FLDxNM    CMERR(7,0)
  232.  
  233. /* don't allow empty fields */
  234. #define FLD_EMPTY 0x0001
  235.  
  236. /* Configuration information for cmswi */
  237.  
  238. #define _CMSWI 8
  239.  
  240. /* Macro to prevent loading of cmswi support */
  241.  
  242. #define SWI_STUB ftspec ft_swi = { NULL, NULL, NULL, 0, NULL }; \
  243.     fnerr fe_swi = { 0, NULL };
  244.  
  245.  
  246. /* switch parsing errors */
  247.  
  248. #define SWIxNM    CMERR(8,0)
  249. #define SWIxAMB    CMERR(8,1)
  250. #define SWIxABR    CMERR(8,2)
  251. #define SWIxBEG    CMERR(8,3)
  252. #define SWIxEND    CMERR(8,4)
  253.  
  254. /*
  255.  * SWTCH structure specifies one entry in a switch table.  SWITAB
  256.  * structure describes a table of switches.  (We use the name
  257.  * swtch instead of switch because the latter is a C reserved word.)
  258.  */
  259.  
  260. typedef struct SWTCH {
  261.     char *    _swswi;        /* switch string (without punctuation)  */
  262.     short    _swflg;        /* flags (see below) */
  263.     int    _swval;        /* arbitrary value, not used internally */
  264.                 /*  except for abbreviations... see SWI_ABR */
  265.                 /*  flag below */
  266. } swtch;
  267.  
  268. typedef struct SWITAB {
  269.     int    _stcnt;        /* number of switches in table */
  270.     swtch  * _stwds;    /* array of switch entries  */
  271. } switab;
  272.  
  273. /* Flags that can be present in a switch entry */
  274.  
  275. #define SWI_ABR 0x0001            /* switch is an abbreviation for the */
  276.                 /* switch indexed by this entry's _swval */
  277.                 /* value */
  278. #define SWI_NOR 0x0002            /* Ignore this switch (do not recognize */
  279.                 /*  any prefix, or even an exact match) */
  280. #define SWI_INV 0x0004            /* Invisible switch (not shown with help) */
  281. #define SWI_MAT 0x0008            /* This switch matches current input (used */
  282.                 /*  internally) */
  283.  
  284. /* Configuration information for cmtok */
  285.  
  286. #define _CMTOK 9
  287.  
  288. /* Macro to prevent loading of cmtok support */
  289.  
  290. #define TOK_STUB ftspec ft_tok = { NULL, NULL, NULL, 0, NULL }; \
  291.     fnerr fe_tok = { 0, NULL };
  292.  
  293. /* token parse errors */
  294.  
  295. #define TOKxNP    CMERR(9,0)
  296.  
  297. /* Wake up on match */
  298. #define TOK_WAK 0x0001
  299.  
  300. /* Configuration information for cmtad */
  301.  
  302. #define _CMTAD 10
  303.  
  304. /* Macro to prevent loading of cmtad support */
  305.  
  306. #define TAD_STUB ftspec ft_tad = { NULL, NULL, NULL, 0, NULL }; \
  307.     fnerr fe_tad = { 0, NULL };
  308.  
  309.  
  310. #include "datime.h"        /* need these symbols to use _CMTAD */
  311.  
  312. /* time/date parse errors */
  313.  
  314. #define TADxNTD    CMERR(10,0)
  315. #define TADxTIM    CMERR(10,1)
  316. #define TADxDAT    CMERR(10,2)
  317. #define TADxDT    CMERR(10,3)
  318.  
  319.  
  320. /* Configuration information for cmfil */
  321.  
  322. #define _CMFIL 11
  323.  
  324. /* Macro to prevent loading of cmfil support */
  325.  
  326. #define FIL_STUB ftspec ft_fil = { NULL, NULL, NULL, 0, NULL }; \
  327.     fnerr fe_fil = { 0, NULL };
  328.  
  329.  
  330. /* filename parse errors */
  331.  
  332. #define FILxNM    CMERR(11,0)
  333. #define FILxAMB    CMERR(11,1)
  334. #define FILxNWLD    CMERR(11,2)
  335. #define FILxINV    CMERR(11,3)
  336. #define FILxBAD    CMERR(11,4)
  337. #define FILxPMA    CMERR(11,5)
  338.  
  339. /*
  340.  * FILBLK structure describes a data block to be passed to the file
  341.  * name parser
  342.  */
  343. typedef struct FILBLK {
  344.     char **pathv;        /* NULL terminated vector of dirs */
  345.     char *exceptionspec;    /* regexp of exceptions */
  346.     char **def_extension;   /* list of extensions to use */
  347. } filblk;
  348.  
  349. /*
  350.  * flags that can be present in a filename fdb 
  351.  */
  352.  
  353. #define FIL_OLD 0x0001            /* existing file */
  354. #define FIL_PO 0x0002            /* nonexisting file */
  355. #define FIL_SDH 0x0004            /* don't give standard help */
  356. #define FIL_DIR 0x0008            /* a directory */
  357. #define FIL_RD 0x0010            /* a readable file */
  358. #define FIL_WR 0x0020            /* a writable file */
  359. #define FIL_EXEC 0x0040            /* an executable file */
  360. #define FIL_HID 0x0080            /* a hidden file (MSDOS) */
  361. #define FIL_SYS 0x0100            /* a system file (MSDOS) */
  362. #define FIL_ALL (FIL_DIR|FIL_RD|FIL_WR|FIL_EXEC|FIL_HID|FIL_SYS)
  363. #define FIL_WLD 0x0200            /* wild cards allowed */
  364. #define FIL_REGEXP 0x0400            /* regexp's allowed */
  365. #define FIL_NOPTH 0x0800            /* only display filename in help */
  366. #define FIL_NOEXT 0x1000            /* don't display extention in help */
  367. #define FIL_TYPE 0x2000            /* display the type of file in help */
  368. #define FIL_NODIR 0x4000            /* don't complete on directories */
  369. #define FIL_RW 0x8000            /* read and write */
  370. typedef char **pvfil;        /* return a NULL terminated string vector */
  371.  
  372.  
  373.  
  374. /* Configuration information for cmusr */
  375.  
  376. #define _CMUSR 12
  377.  
  378. /* Macro to prevent loading of cmusr support */
  379.  
  380. #define USR_STUB ftspec ft_usr = { NULL, NULL, NULL, 0, NULL }; \
  381.     fnerr fe_usr = { 0, NULL };
  382.  
  383.  
  384. /* username parse errors */
  385. #define USRxNM    CMERR(12,0)
  386. #define USRxAMB    CMERR(12,1)
  387.  
  388. /* parse a wild username */
  389. #define USR_WILD 0x0001                /* allow wild users */
  390. #define USR_NOUPD 0x0002                /* defer update of user table */
  391.                     /* even if /etc/passwd has been  */
  392.                     /* updated */
  393. #define USR_UPDONLY 0x0004                /* forced update of user table */
  394.                     /* parse will fail. */
  395.                     /* allows table to updated with  */
  396.                     /* no parse done. */
  397.                     /* when using this flag, you */
  398.                     /* must trap errors yourself, or */
  399.                     /* a "no such user error" will be */
  400.                     /* displayed */
  401. #if unix
  402. #include <pwd.h>
  403. #else
  404. struct passwd {
  405.   int x;
  406. };
  407. #endif
  408.  
  409. /* Configuration information for cmgrp */
  410.  
  411. #define _CMGRP 13
  412.  
  413. /* Macro to prevent loading of cmgrp support */
  414.  
  415. #define GRP_STUB ftspec ft_grp = { NULL, NULL, NULL, 0, NULL }; \
  416.     fnerr fe_grp = { 0, NULL };
  417.  
  418.  
  419.  
  420. /* groupname parse errors */
  421. #define GRPxNM    CMERR(13,0)
  422. #define GRPxAMB    CMERR(13,1)
  423.  
  424. #define GRP_WILD 0x0001                /* allow wild groups */
  425. #define GRP_NOUPD 0x0002                /* defer update of group table */
  426.                     /* even if /etc/group has been  */
  427.                     /* updated */
  428. #define GRP_UPDONLY 0x0004                /* forced update of group table */
  429.                     /* parse will fail. */
  430.                     /* allows table to updated with  */
  431.                     /* no parse done. */
  432.  
  433. #if unix
  434. #include <grp.h>
  435. #else
  436. struct group {
  437.   int x;
  438. };
  439. #endif
  440.  
  441. /* Configuration information for cmpara */
  442.  
  443. #define _CMPARA 14
  444.  
  445. /* Macro to prevent loading of cmpara support */
  446.  
  447. #define PARA_STUB ftspec ft_para = { NULL, NULL, NULL, 0, NULL }; \
  448.     fnerr fe_para = { 0, NULL };
  449.  
  450.  
  451. /*
  452.  * para_actions:
  453.  * a structure to hold an action character, and an associated function
  454.  * to call for that action
  455.  */
  456.  
  457. typedef struct {
  458.   char actionchar;
  459.   char * (* actionfunc)();
  460. } para_actions;
  461.  
  462. /*
  463.  * para_data:
  464.  * input data to paragraph parser.
  465.  * holds text to install at the beginning of the buffer, and
  466.  * a NULL terminated vector of para_actions.
  467.  */
  468.  
  469. typedef struct {
  470.   char *buf;
  471.   para_actions *actions;
  472. } para_data;
  473.  
  474. #define PARAxNM    CMERR(14,0)
  475.  
  476. /*
  477.  * the PARA_DEF flag is used to specify that the default actions should be
  478.  * set, and then the user specified actions should be installed.
  479.  * Used to make additions to the default actions
  480.  */
  481. #define PARA_DEF 0x0001
  482.  
  483. #ifndef DEF_EDITOR
  484. #if unix
  485. #define DEF_EDITOR "emacs"
  486. #endif
  487.  
  488. #ifdef MSDOS
  489. #ifdef RAINBOW
  490. #define DEF_EDITOR "mince"
  491. #else
  492. #define DEF_EDITOR "epsilon"
  493. #endif /*  RAINBOW */
  494. #endif /*  MSDOS */
  495. #endif
  496. ;
  497.  
  498.  
  499. /* Configuration information for cmchar */
  500.  
  501. #define _CMCHAR 15
  502.  
  503. /* Macro to prevent loading of cmchar support */
  504.  
  505. #define CHAR_STUB ftspec ft_char = { NULL, NULL, NULL, 0, NULL }; \
  506.     fnerr fe_char = { 0, NULL };
  507.  
  508.  
  509. /* Union declaration for parse return values */
  510.  
  511. typedef union PVAL {
  512.     int _pvint;
  513.     float _pvflt;
  514.     char _pvchr;
  515.     char *_pvstr;
  516.     char **_pvstrvec;
  517.         keyval _pvkey;
  518.         datime _pvtad;
  519.         pvfil _pvfil;
  520.         struct passwd ** _pvusr;
  521.         struct group ** _pvgrp;
  522.         char * _pvpara;
  523. } pval;
  524.